<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        //统计字符串中“aaaabbbccccddfgh”中字母个数或统计最多字母数

        function distinction(str) {
            var obj = {};
            return (function () {
                for (var i =0; i <str.length; i++) {
                    var V = str.charAt(i);
                    if (obj[v] && obj[v].value == v) {
                        obj[v].count = ++obj[v].count;
                    }
                    else{
                        obj[v] = {};
                        obj[v].count = 1;
                        obj[v].value = V;
                    }
                    
                }
                return obj
            })()
        }
        var str = "aaabbbbbddddddd";
        console.log(distinction(str))
    </script>
</body>

</html>